<?php

namespace App\Http\Requests\Entity\Asset\Video;

use App\Http\Requests\Request;

class VserialiRequest extends Request
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        'vseriali_no'   => 'required|unique:vserialis,vseriali_no',
                        'name'          => 'required|max:100',
                        'title'         => 'max:100',
                        'subtitle'      => 'max:100',
                        'episode'       => 'required|numeric',
                        'score'         => 'numeric',
                        'vasseti_id'    => 'required',
                        'firstdate'     => 'date',
                        'online_at'     => 'date',
                        'offline_at'    => 'date',
                        'short_desc'    => 'required',
                        'listorder'  => 'required',
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    $id = $this->route('vserialis');
                    return [
                        'vseriali_no'   => 'required|unique:vserialis,vseriali_no,' . $id,
                        'name'          => 'required|max:100',
                        'title'         => 'max:100',
                        'subtitle'      => 'max:100',
                        'episode'       => 'required|numeric',
                        'score'         => 'numeric',
                        'vasseti_id'    => 'required',
                        'firstdate'     => 'date',
                        'online_at'     => 'date',
                        'offline_at'    => 'date',
                        'short_desc'    => 'required',
                        'listorder'  => 'required',
                    ];
                }
            default:
                break;
        }
    }
     public function messages()
    {
        return [
            'vseriali_no.required' => '分集编号 不能为空',
            'vasseti_id.required'    => '所属的剧集 不能为空',
            'name.required'       => '分集名称 不能为空',
            'short_desc.required' => '简介 不能为空',
            'title.max'           => '标题 不能大于100个字符',
            'subtitle.max'        => '副标题 不能大于100个字符',
            'firstdate.date'     => '首播日期 不是一个有效的日期',
            'online_at.date'     => '上线日期 不是一个有效的日期',
            'offline_at.date'    => '下线日期 不是一个有效的日期',
            'episode.required'       => '集数 不能为空',


        ];
    }
}
